<!DOCTYPE html>
<html>
<head>
    <title>getElementsByName() Example</title>
</head>
<body>
    <fieldset>
        <legend>Which color do you prefer?</legend>
        <ul>
            <li><input type="radio" value="red" name="color" id="colorRed">
                <label for="colorRed">Red</label></li>
            <li><input type="radio" value="green" name="color" id="colorGreen">
                <label for="colorGreen">Green</label></li>
            <li><input type="radio" value="blue" name="color" id="colorBlue">
                <label for="colorBlue">Blue</label></li>
        </ul>
    </fieldset>
    <input type="button" value="Get Radios" onclick="getRadios()">
    <script type="text/javascript">
        function getRadios(){
            alert("Radio count: " + document.getElementsByName("color").length);
        }
    
    </script>
</body>
</html>